package com.ict.web.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ict.common.annotation.Excel;
import com.ict.common.utils.bean.BeanUtils;
import com.ict.common.utils.uuid.IdUtils;
import com.ict.web.controller.file.domain.YzqFile;
import com.ict.web.domain.LastCheck;
import com.ict.web.domain.ProjectManagement;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;

@Data
public class LastCheckAddDto {
    /** 项目id */
    @ApiModelProperty(value = "项目id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @NotNull(message = "项目id不能为空")
    private Long proId;


    /** 终验通过时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "终验通过时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date lastAdoptTime;

    /** 验收机构名称 */
    @Excel(name = "验收机构名称")
    private String checkName;

    /** 终验通过凭证 */
    @Excel(name = "终验通过凭证")
    private YzqFile lastAdoptVoucher;

    /**
     * 将 LastCheckAddDto 转化为 LastCheck
     *
     * @param dto 接收dto
     * @return HotelInfo
     */
    public static LastCheck of(LastCheckAddDto dto){
        LastCheck bean = new LastCheck();
        BeanUtils.copyProperties(dto,bean);

        //设置ID
        bean.setLastCheckId(IdUtils.snowId());
        //设置创建时间
        bean.setCreateTime(LocalDateTime.now());
        //设置创建时间
        bean.setUpdateTime(LocalDateTime.now());
        //设置物理删除标记
        bean.setIsDelete("0");

        return bean;
    }
}
